<?php
session_start();
var_dump($_SESSION);

include('db.php');
$sql="SELECT * FROM livingMessage ORDER BY id DESC";
$mysqli_result=$mysqli->query($sql);

//从数据库取出留言数据
$rows=array();
while($row=$mysqli_result->fetch_array(MYSQLI_ASSOC)){

    $rows[]=$row;
}

//var_dump($rows);
?>

<!doctype html>
<html class="no-js" lang="">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>留言板</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="manifest" href="site.webmanifest">
    <link rel="apple-touch-icon" href="icon.png">
    <!-- Place favicon.ico in the root directory -->

    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="style.css">
</head>
<body>

<!--<p id="a" class="asd">Hello world! This is HTML5 Boilerplate.</p>-->
<!--<a href="https://www.baidu.com/">百度一下,你就知道</a>-->
<!--<img src="./img/v2-59c3ff6c0db18401ad9697d51cdb76d2_hd 2.jpg" width="360"/>-->

<div class="add">
    <form action="http://localhost:8888/indexPro.php" method="post">
        <textarea title="不知道" name="content">留言内容</textarea>
        <input class="user" name="user" type="text" title="这是什么啊">
        <input class="btn" type="submit" value="发表">
        <a href="login.php">登录</a>
    </form>
</div>

<div class="msg">
<?php
foreach ($rows as $row){
    $time = date("Y-m-d H:i:s",$row['intime']);
?>
    <div class="item">
        <span class="user"><?php echo $row['username'];?></span>
        <span class="time"><?php echo $time;?></span>
        <div style="clear:both;"></div>
        <p><?php echo $row['content'];?></p>
    </div>
<?php
}
?>



</div>

